package com.example.basicSpringBoot.controller;

import com.example.basicSpringBoot.entity.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class IndexController {
	@RequestMapping("/hello")
	public String hello(@RequestParam(value = "name", defaultValue = "value") String name) {
		return String.format("Hello %s ,hello %s", name, name);
	}

	@PostMapping("post")
	public User post(User user){
		System.out.println(user.toString());
		return user;
	}
	@PostMapping("jsonPost")
	public User jsonPost(User user, HttpServletRequest request){
		System.out.println(user.toString());
		return user;
	}
}
